#include "audio.h"

bool audio_com::play(){
    return false;
}


bool audio_com::open(){
    fd = fopen("/dev/MX", "r+");
    if(fd == NULL )
    {
        return false;
    }
    boost::function0<void> f = boost::bind(&audio::play,this);
    this->thread_p = new boost::thread(f);
}

bool audio_com::open(char *fp){
    fd = fopen(fp, "r+");
    return false;
}

bool audio_com::contrl(int command)
{
    switch (command) {
    case PLAY:case NC:case PAUSE:case STOP:
        //this->command(command);
        return true;
        break;
    default:
        break;
    }
    return false;
}

bool audio_com::pause()
{

    return false;
}

bool audio_com::close(){
    if(fclose(fd)){
       return true;
    }
    return false;
}

bool audio::play(int times){
    return false;
}

int audio::stop(){
    return 0;
}
bool audio::read(char *fp, int len, int val){
    return false;
}
bool audio::write(char *fp, int len, int val){
    return false;
}

audio::audio(string name,ioctrl io,string app_path,string sql_path)
{
    this->name = name;
    operatinmod<audio_com,audio_input>(name);
}

void audio::set_contrl(singal::source sour, string path)
{
    singal sign;
    sign.source=sour;
    sign.path = path;
    this->singals.insert("contrl",sign);
}

void audio::set_play(singal::source sour, string path)
{
    singal sign;
    sign.source=sour;
    sign.path = path;
    this->singals.insert("contrl",sign);
}
